from concurrent import futures
import logging

import grpc
from mxshop_src.user_srv.proto import user_pb2_grpc
from mxshop_src.user_srv.handle import user
from loguru import logger

def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    user_pb2_grpc.add_UserServicer_to_server(user.UserServicer(), server)
    server.add_insecure_port('[::]:50053')
    logger.info("服务启动了")
    server.start()
    server.wait_for_termination()


if __name__ == '__main__':
    logging.basicConfig()
    serve()